package com.zzrc.grape.controller;

import com.zzrc.grape.model.user.MobileReq;
import com.zzrc.grape.service.*;
import com.zzrc.grape.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;


/**
 * 用户管理Controller
 * @author yuanweixin
 */
@Controller
@RequestMapping("/user")
public class UserController {
	protected Logger logger = LoggerFactory.getLogger(getClass());
	@Resource
	UserService userService;

	/**
	 * 去添加白名单页面
	 *
	 * @return modelView
	 */
	@RequestMapping("goAddWhiteListIndex")
	public ModelAndView goAddWhiteListIndex() {
		ModelAndView modelView = new ModelAndView();
		modelView.setViewName("/user/addWhiteListIndex");
		return modelView;
	}

	/**
	 * 添加白名单
	 *
	 * @return true or false
	 */
	@PostMapping("addWhiteList")
	@ResponseBody
	public BasePageData addWhiteList(String idCard) throws Exception {
		return userService.addWhiteList(idCard);
	}

	/**
	 * 去清除用户页面
	 *
	 * @return modelView
	 */
	@RequestMapping("goDeleteUserIndex")
	public ModelAndView goDeleteUserIndex() {
		ModelAndView modelView = new ModelAndView();
		modelView.setViewName("/user/deleteUserIndex");
		return modelView;
	}

	/**
	 * 清除用户信息
	 *
	 * @return true or false
	 */
	@PostMapping("deleteUser")
	@ResponseBody
	public BasePageData deleteUser(String mobile) throws Exception {
		return userService.deleteUser(mobile);
	}

	@RequestMapping("goResetUserAccountIndex")
	public ModelAndView goResetUserAccountIndex() {
		ModelAndView modelView = new ModelAndView();
		modelView.setViewName("/user/resetUserAccountIndex");
		return modelView;
	}

	@RequestMapping("goUserInfoSelectIndex")
	public ModelAndView goUserInfoSelectIndex() {
		ModelAndView modelView = new ModelAndView();
		modelView.setViewName("/user/userInfoSelectIndex");
		return modelView;
	}

	/**
	 * 重置用户额度
	 *
	 * @return true or false
	 */
	@PostMapping("resetUserAccount")
	@ResponseBody
	public BasePageData resetUserAccount(String mobile) {
		return userService.resetUserAccount(mobile);
	}

//	/**
//	 * 用户信息查询
//	 *
//	 * @return true or false
//	 */
//	@PostMapping("userInfoSelect")
//	@ResponseBody
//	public BasePageData userInfoSelect(String mobile){
//		return userService.userInfoSelect(mobile);
//	}

	/**
	 * 用户信息查询
	 *
	 * @return BasePageData
	 */
	@PostMapping("getUserBaseList")
	@ResponseBody
	public BasePageData getUserBaseList(@RequestBody MobileReq mobileReq){
		String mobile = mobileReq.getMobile();
		return userService.getUserBaseList(mobile);
	}

	/**
	 * 用户实名信息查询
	 *
	 * @return BasePageData
	 */
	@PostMapping("getUserIdentityList")
	@ResponseBody
	public BasePageData getUserIdentityList(@RequestBody MobileReq mobileReq){
		String mobile = mobileReq.getMobile();
		return userService.getUserIdentityList(mobile);
	}

	/**
	 * 用户银行卡信息查询
	 *
	 * @return BasePageData
	 */
	@PostMapping("getBankCardList")
	@ResponseBody
	public BasePageData getBankCardList(@RequestBody MobileReq mobileReq){
		String mobile = mobileReq.getMobile();
		return userService.getBankCardList(mobile);
	}

	/**
	 * 用户授信信息查询
	 *
	 * @return BasePageData
	 */
	@PostMapping("getLogUserStatusList")
	@ResponseBody
	public BasePageData getLogUserStatusList(@RequestBody MobileReq mobileReq){
		String mobile = mobileReq.getMobile();
		return userService.getLogUserStatusList(mobile);
	}

	/**
	 * 用户额度查询
	 *
	 * @return BasePageData
	 */
	@PostMapping("getUserAccountList")
	@ResponseBody
	public BasePageData getUserAccountList(@RequestBody MobileReq mobileReq){
		String mobile = mobileReq.getMobile();
		return userService.getUserAccountList(mobile);
	}

	/**
	 * 用户借款信息查询
	 *
	 * @return BasePageData
	 */
	@PostMapping("getRecordLoanList")
	@ResponseBody
	public BasePageData getRecordLoanList(@RequestBody MobileReq mobileReq){
		String mobile = mobileReq.getMobile();
		return userService.getRecordLoanList(mobile);
	}
}
